load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "rule",
    srcs = [
        "collect_column_stats_usage.go",
        "logical_rules.go",
        "rule_build_key_info.go",
        "rule_collect_plan_stats.go",
        "rule_column_pruning.go",
        "rule_constant_propagation.go",
        "rule_init.go",
        "rule_partition_processor.go",
        "rule_predicate_simplification.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/planner/core/rule",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/domain",
        "//pkg/expression",
        "//pkg/infoschema",
        "//pkg/meta/model",
        "//pkg/parser/ast",
        "//pkg/parser/mysql",
        "//pkg/planner/core/base",
        "//pkg/planner/core/constraint",
        "//pkg/planner/core/operator/logicalop",
        "//pkg/planner/core/rule/util",
        "//pkg/planner/planctx",
        "//pkg/planner/util",
        "//pkg/planner/util/utilfuncp",
        "//pkg/sessionctx/vardef",
        "//pkg/statistics",
        "//pkg/statistics/asyncload",
        "//pkg/table",
        "//pkg/table/tables",
        "//pkg/types",
        "//pkg/util/chunk",
        "//pkg/util/collate",
        "//pkg/util/filter",
        "//pkg/util/hint",
        "//pkg/util/intest",
        "//pkg/util/intset",
        "//pkg/util/logutil",
        "//pkg/util/mathutil",
        "//pkg/util/plancodec",
        "//pkg/util/ranger",
        "//pkg/util/set",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_tipb//go-tipb",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "rule_test",
    timeout = "short",
    srcs = [
        "collect_column_stats_usage_test.go",
        "rule_partition_pruning_test.go",
    ],
    flaky = True,
    shard_count = 13,
    deps = [
        ":rule",
        "//pkg/expression",
        "//pkg/infoschema",
        "//pkg/meta/model",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/planner/core",
        "//pkg/planner/core/base",
        "//pkg/planner/core/resolve",
        "//pkg/planner/util/coretestsdk",
        "//pkg/session",
        "//pkg/testkit/ddlhelper",
        "//pkg/testkit/testfailpoint",
        "//pkg/types",
        "//pkg/util/hint",
        "//pkg/util/mock",
        "@com_github_stretchr_testify//require",
    ],
)
